/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projeto.voztg.pkg2.pkg0;

/**
 *
 * @author nascimento lima
 */
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class WordsReplace {

    public static WordsReplace instance;
    public static Properties wordsReplaceFileProperties;

    static {
        if (instance == null) {
            instance = new WordsReplace();
        }
    }

    public WordsReplace() {
        Erro.setErro(false);
        File file = new File(Config.getCaminhoOutPut() + Config.getNome_Arq_Replace());

        if (file.exists() != true) {
            Erro.setErro("arquivo de reposição de palavras foi apagado");
        }
        wordsReplaceFileProperties = new Properties();
        try {
            FileInputStream fis = new FileInputStream(file);
            wordsReplaceFileProperties.load(fis);
            fis.close();
        } catch (IOException ex) {
            Erro.setErro(ex.getMessage());
        }


    }

    public String getReplacedWord(String keyWord) {
        if (wordsReplaceFileProperties != null) {
            return wordsReplaceFileProperties.getProperty(keyWord);
        }
        return null;
    }

    public static WordsReplace getInstance() {
        return instance;
    }

    public static void RecarregarReplace() {
        instance = new WordsReplace();

    }
}
